package com.msmall.base.service;

import java.io.Serializable;
import java.util.List;

import com.msmall.base.pager.PaginationSupport;


@SuppressWarnings("unchecked")
public interface BaseManager <T, PK extends Serializable> {

    /**
     * Generic method to get an object based on class and identifier. An
     * ObjectRetrievalFailureException Runtime Exception is thrown if
     * nothing is found.
     *
     * @param id the identifier (primary key) of the object to get
     * @return a populated object
     * @see org.springframework.orm.ObjectRetrievalFailureException
     */
    T get(PK id);
    Object get(Class clazz, Serializable id);
    
    /**
     * Generic method used to get all objects of a particular type. This
     * is the same as lookup up all rows in a table.
     * @return List of populated objects
     */
    List<T> getAll();
    List getAll(Class clazz);
    
    /**
     * Generic method to save an object - handles both update and insert.
     * @param object the object to save
     * @return the updated object
     */
    T save(T object);
    public Object saveObject(Object obj);
    /**
     * Generic method to delete an object based on class and id
     * @param id the identifier (primary key) of the object to remove
     */
    void remove(PK id);
    void remove(Class clazz, Serializable id);
    
    /**
     * Checks for existence of an object of type T using the id arg.
     * @param id the identifier (primary key) of the object to get
     * @return - true if it exists, false if it doesn't
     */
    boolean exists(PK id);
    boolean exists(Class clazz, Serializable id);
    
    /**
     * get pagination entities
     * @param page
     */
    void getPagination(PaginationSupport page);

}
